package com.leetcode.Offer;

import java.util.*;

public class JZ48 {
    public int lengthOfLongestSubstring(String s) {
        //滑动窗口，用list维护一个不重复的窗口
        char[] chars = s.toCharArray();
        int maxSize = 0;
        List<Character> list = new LinkedList<>();
        for (int i = 0; i < s.length(); i++) {
            char tmp = chars[i];
            while (list.contains(tmp)) {
                list.remove(0);
            }
            list.add(tmp);
            maxSize = Math.max(maxSize, list.size());
        }
        return maxSize;
    }

    public int lengthOfLongestSubstring2(String s) {
        //动态规划
        char[] chars = s.toCharArray();
        int[] dp = new int[s.length() + 1];
        dp[0] = 1;
        dp[1] = 1;
        int maxSize = 0;
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char tmp = chars[i];


        }
        return maxSize;
    }

    public static void main(String[] args) {
        System.out.println(new JZ48().lengthOfLongestSubstring("aab"));
    }
}
